﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.ZY
{
    /// <summary>
    /// 生命附加豁免保险费重大疾病保险
    /// </summary>
    class Class8
    {
        /// <summary>
        /// 重大疾病豁免保险费
        /// </summary>
        /// <param name="ppa"></param>
        /// <param name="da"></param>
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.HolderStates.Contains("重疾"))
            {
                foreach (IPolicyPeriodActing p2 in ppa.SchemePeriodActing.PolicyPeriodActings)
                {
                    p2.Fee = 0;
                }

                ppa.IsCurrentFinish = true;
            }
        }
        /// <summary>
        /// 身故豁免保险费（仅适用于主保险合同投保人与主保险合同被保险人不是同一人的情形）
        /// </summary>
        /// <param name="ppa"></param>
        /// <param name="da"></param>
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("一般失能"))
            {
                if (ppa.Period == 0)
                {
                    da.Value = ppa.TotalFee;
                    ppa.IsCurrentFinish = true;
                }
                else
                {
                    string level = ppa.SchemePeriodActing.SchemeActing.GetAuxConfigValue("一般失能等级").ToString();

                    double x = 0d;

                    if (level == "第一级")
                    {
                        x = ppa.Amount * 0.65;
                    }
                    else if (level == "第二级")
                    {
                        x = ppa.Amount * 0.5;
                    }
                    else if (level == "第三级")
                    {
                        x = ppa.Amount * 0.35;
                    }

                    double t =ppa.Amount- ppa.GetDutyTotalValue("一般失能等级");

                    da.Value = x > t ? t : x;
                }
            }
        }
    }
}
